//
//  YDYTopicVideoView.m
//  DYSisterAPP
//
//  Created by 杨德勇 on 2016/8/7.
//  Copyright © 2016年 杨德勇. All rights reserved.
//

#import "YDYTopicVideoView.h"
#import <UIImageView+WebCache.h>
#import <DALabeledCircularProgressView.h>
#import "YDYTopic.h"
@interface YDYTopicVideoView()
@property (weak, nonatomic) IBOutlet UIImageView *imgView;
@property (weak, nonatomic) IBOutlet UIButton *playBtn;
@property (weak, nonatomic) IBOutlet DALabeledCircularProgressView *progressView;
@property (weak, nonatomic) IBOutlet UILabel *playCountLabel;
@property (weak, nonatomic) IBOutlet UILabel *videoTimeLabel;

@end
@implementation YDYTopicVideoView

-(void)awakeFromNib{
     [super awakeFromNib];
    self.autoresizingMask = UIViewAutoresizingNone;
}

-(void)setTopic:(YDYTopic *)topic{
    _topic = topic;
    
    [self.imgView sd_setImageWithPreviousCachedImageWithURL:[NSURL URLWithString:self.topic.large_img] placeholderImage:nil options:0 progress:^(NSInteger receivedSize, NSInteger expectedSize) {
        self.progressView.hidden = NO;
        CGFloat progress = receivedSize * 1.0 /expectedSize;
        self.progressView.progress = progress;
        
        self.progressView.progressLabel.text = [NSString stringWithFormat:@"%.2f",progress];
        self.progressView.progressLabel.textColor = [UIColor darkGrayColor];
    } completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        self.progressView.hidden = YES;
    }];
    //播放次数设置
    self.playCountLabel.text = [NSString stringWithFormat:@"%zd播放",topic.playcount];
    self.playCountLabel.textColor = [UIColor whiteColor];
    //播放时长
    self.videoTimeLabel.text = [NSString stringWithFormat:@"%02zd:%02zd",topic.videotime / 60,topic.videotime % 60];
    self.videoTimeLabel.textColor = [UIColor whiteColor];
    
    
}


@end
